package business
{
	import com.adobe.cairngorm.business.ServiceLocator;
	
	import mx.collections.ItemResponder;
	import mx.rpc.AsyncToken;
	import mx.rpc.remoting.RemoteObject;
	
	public class LogDelegate
	{
		private var responder:Object;
        private var service:RemoteObject;			
		
		public function LogDelegate(re:Object)
		{
	        this.service = ServiceLocator.getInstance().getRemoteObject("logService");
            this.responder = re;			
		}
		
        public function log(obj:Object):void
        {
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.log(obj);
            itemResponder = new ItemResponder(responder["logResult"],responder["fault"] );
            token.addResponder(itemResponder);          
        }
        
        public function getLogs(page:int=0):void
        {
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.getLogs(page);
            itemResponder = new ItemResponder(responder["getResult"],responder["fault"] );
            token.addResponder(itemResponder);          
        }
        
        public function search(obj:Object, page:int):void
        {
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.search(obj, page);
            itemResponder = new ItemResponder(responder["getResult"],responder["fault"] );
            token.addResponder(itemResponder);          
        } 
        
        public function setOpt(id:String, opt:int):void
        {
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.setOpt(id, opt);
            itemResponder = new ItemResponder(responder["setOptResult"],responder["fault"] );
            token.addResponder(itemResponder);          	
        }                
        		

	}
}